/* Copyright 2010 John L. Reilly

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

package com.riq.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Location implements Serializable {

  private static final long serialVersionUID = 1L;
  
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    public Long key;	
	
  	@Persistent
  	private Long deptId;
  	
  	@Persistent
  	private String shortName;
  	
  	@Persistent
  	private String longName; 
  	
  	@Persistent
  	private String type;
  	
  	@Persistent
    private String special;
  	
  	@Persistent
  	private int sequence;
  	
  	@Persistent
    private String vru;
  	  
  	@Persistent
  	private Long timeStamp;
	
    @Persistent
    private String lastLat;
   
    @Persistent
    private String lastLng;
  
    @Persistent
    private Long gpsTimeStamp;
  
    @Persistent
    private String gpsAccuracy;
  
    @Persistent
    private String latitudeId;
  
    @Persistent
    private Long targetObjectId;
  
    @Persistent
    private String targetObjectType;
  
    @Persistent
    private String position;
  
    @Persistent
    private Double distance;
    
    @Persistent(defaultFetchGroup = "true")
    public Set<Long> statusKeys = new HashSet<Long>();
    
    @Persistent
    private Long selectedStatus;
    
    public void addStatus(Status status) {
      if (statusKeys == null) {
          statusKeys = new HashSet<Long>();
      }
      statusKeys.add(status.getid());
  }
	
	public Location(
	    Long deptId, 
	    String shortName, 
	    String longName, 
	    String type, 
      String special, 
      int sequence, 
      String vru, 
      Long timeStamp, 
      String lastLat, 
      String lastLng, 
      Long gpsTimeStamp, 
      String gpsAccuracy, 
      String latitudeId, 
      Long targetObjectId,
      String targetObjectType, 
      String position, 
      Double distance, 
      Set<Long> statusKeys,
      Long selectedStatus) {
	  
  	 this.deptId = deptId;
  	 this.shortName = shortName;
  	 this.longName = longName;
  	 this.type = type; 
     this.special = special;  
  	 this.sequence = sequence;
  	 this.vru = vru;
  	 this.timeStamp = timeStamp;
     this.lastLat = lastLat;
     this.lastLng = lastLng;
     this.gpsTimeStamp = gpsTimeStamp;
     this.gpsAccuracy = gpsAccuracy;
     this.latitudeId = latitudeId;
     this.targetObjectId = targetObjectId;
     this.targetObjectType = targetObjectType;
     this.position = position;
     this.distance = distance;
     this.statusKeys = statusKeys;
     this.selectedStatus = selectedStatus;
	}
	
	
	
// VERBS
	
  public boolean hasGoogleLatitudeAcct() {
    return latitudeId != null;
  }
    
  public boolean ownedByDept(final Long pamId) {
    return this.getdeptId().equals(pamId);
  }
  
  public boolean hasThisStatus(final Status s) {
    return this.statusKeys.contains(s);
  }
  
//  public boolean thisStatusSelected(final Status s) {
//    return this.selectedStatus.equals(s.getid());
//  }

	
// GETS

	public Long getid() {
		return key;
	}

	public Long getdeptId() {
		return deptId;
	}

	public String getshortName() {
		return shortName;
	}

	public String getlongName() {
		return longName;
	}
	
	public String gettype() {
		return type;
	}
	 
  public String getspecial() {
    return special;
  }
  
	public int getsequence() {
		return sequence;
	}
	
	 public String getvru() {
	    return vru;
	}
	
	public Long gettimeStamp() {
		return timeStamp;
	}
	
	public String getlastLat() {
	  return lastLat;
  }

  public String getlastLng() {
    return lastLng;
	}

  public Long getgpsTimeStamp() {
    return gpsTimeStamp;
  }

  public String getgpsAccuracy() {
    return gpsAccuracy;
  }

  public String getlatitudeId() {
    return latitudeId;
  }

  public String getposition() {
    return position;
  }

  public Long gettargetObjectId() {
    return targetObjectId;
  }

  public String gettargetObjectType() {
    return targetObjectType;
  }

  public Double getdistance() {
    return distance;
  }
  
  public Set<Long> getstatusKeys() {
    return statusKeys;
  }
  
  public Long getselectedStatus() {
    return selectedStatus;
  }

// SETS
	

  public void setkey(Long key) {
    // TODO Auto-generated method stub
  }
  
	public void setdeptId(Long deptId) {
		this.deptId = deptId;
	}
	
	public void setshortName(String shortName) {
		this.shortName = shortName;
	}
	
	public void setlongName(String longName) {
		this.longName = longName;
	}
	
	public void settype(String type) {
		this.type = type;
	}
	 
  public void setspecial(String special) {
    this.special = special;
  }
  
	public void setsequence(int sequence) {
		this.sequence = sequence;
	}
	
	public void setvru(String vru) {
        this.vru = vru;
    }
	 
	public void settimeStamp(Long timeStamp) {
		this.timeStamp = timeStamp;
	}
	
  public void setlastLat(String lastLat) {
    this.lastLat = lastLat;
  } 
	
  public void setlastLng(String lastLng) {
    this.lastLng = lastLng;
  }
  
  public void setgpsTimeStamp(Long gpsTimeStamp) {
    this.gpsTimeStamp = gpsTimeStamp;
  }
  
  public void setgpsAccuracy(String gpsAccuracy) {
    this.gpsAccuracy = gpsAccuracy;
  }

  public void setlatitudeId(String latitudeId) {
    this.latitudeId = latitudeId;
  }
 
  public void settargetObjectId(Long targetObjectId) {
    this.targetObjectId = targetObjectId;
  }
  
  public void settargetObjectType(String targetObjectType) {
    this.targetObjectType = targetObjectType;
  }
  
  public void setposition(String position) {
    this.position = position;
  }
  
  public void setdistance(Double distance) {
    this.distance = distance;
  }
  
  public void setstatusKeys(Set<Long> statusKeys) {
    this.statusKeys = statusKeys;
  }
  
  public void setselectedStatus(Long selectedStatus) {
    this.selectedStatus = selectedStatus;
  }

	
}